package com.qingke.oo.List;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class HR {
	
	List<Employee> list;
	
	public HR(){
		list = new LinkedList<Employee>();
		char j = 'a';
		for(int i = 0; i<20; i++){
			j++;
			Employee e = new Employee((""+j),i,i*100);
			list.add(e);
		}
	}
	
	public List<Employee> getEmployee(){
		return list;
	}
	
	public Employee getTopSalaryEmployee(){
		double max = list.get(0).getSalary();
		int index = 0;
		for(int i=1;i<list.size();i++){
			if(max<list.get(i).getSalary()){
				max = list.get(i).getSalary();
				index = i;
			}
		}
		
		return list.get(index);
	}
	
	public List<Employee> getTop10SalaryEmployee(){
		List<Employee> l = new ArrayList<Employee>(10);
		int count = 0;
		do{
			double max = list.get(0).getSalary();
			int index = 0;
			for(int i=1;i<list.size();i++){
				if(max<list.get(i).getSalary()){
					max = list.get(i).getSalary();
					index = i;
				}
			}
			count++;
			l.add(list.get(index));
			list.remove(index);
		}while(count<11);
		
		return l;
	}
	
	public void enrollEmployee(){
		Employee e = new Employee(""+(Math.random()*50),list.size(),list.size()*100);
		list.add(e);
	}
	
	public void resignEmployee(int employeeID){
		list.remove(employeeID);
	}
	
	public boolean isOurEmployee(Employee employee){
		return list.contains(employee);
	}
}
